<include file="__THEME__/common/header" />
<script language="javascript">
$(function(){
	$('#datagrid').treegrid({
		title:'{$page_title}',
		width:'100%',
		rownumbers: true,
		animate:true,
		collapsible:true,
		url:'{:U("Category/categoryList")}&d='+Math.random(),
		idField:'id',
		treeField:'name',
		frozenColumns:[[
			{field:'id',title:'ID',width:30},
			{title:'分类名称',field:'name',width:150}
		]],
		columns:[[
			{field:'status',title:'状态',width:50},
			{field:'sort',title:'排序',width:80},
			{field:'add_time',title:'添加时间',width:120},
			{field:'remark',title:'备注',width:100},
			{field:'opt',title:'操作',width:180, formatter:function(v, r){
				return '<div class="opt"><a href="javascript:;" onclick="toProduct('+r.id+')" class="view">产品列表</a><a href="javascript:;" onclick="toEdit('+r.id+')" class="edit">编辑</a><a href="javascript:;" onclick="doDelete('+r.id+')" class="delete">删除</a></div>';}}
		]]
	});
});
function toProduct(id){
	window.location.href = '{:U("Product/index")}&id='+id;
}
function toEdit(id){
	window.location.href = '{:U("Category/edit")}&id='+id;
}
function doDelete(id){
	$.messager.confirm('提示', '确定删除该属性组吗？', function(r){
		if (r){
			$.ajax({
				url : '{:U("Category/deleteCategory")}',
				data : 'id='+id,
				dataType: 'json',
				success : function(d){
					if(d.status == 0){
						alertText(d.info, 'error');
					}else{
						$('#datagrid').treegrid('reload');
					}
				}
			});
		}
	});
}
</script>
<div class="box">
<table id="datagrid"></table>
</div>
<include file="__THEME__/common/footer" />